package twentytwenty;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2020-12-05 13:44
 * @Modified By:
 */
public class TitleToNumber_171 {
    public static void main(String [] args){
        String s = "AAA";
        System.out.println(titleToNumber(s));
    }

    public static int titleToNumber(String s) {
        int result = 0;
        for(int i=0;i<s.length();i++) {
            int num = s.charAt(i) - 'A' + 1;
            result = result * 26 + num;
        }
        return result;
    }
}
